import type { NotificationAPI } from 'rc-notification'
import { useNotification } from 'rc-notification'
import { useEffect, useRef } from 'react'
import type { Root } from 'react-dom/client'
import { createRoot } from 'react-dom/client'
import styles from './index.module.scss'

function Notification() {
  const Portal = () => {
    return <div className={styles.notification}>
    弹框
    </div>
  }
  const holderFragment = useRef<HTMLDivElement>()
  const root = useRef<Root>()
  useEffect(() => {
    holderFragment.current = document.createElement('div')
    root.current = createRoot(holderFragment.current)
    document.body.appendChild(holderFragment.current)
  }, [])
  const open = () => {
    root.current.render(<Portal />)
  }

  return { open }
}

export default Notification
